package com.lianrui.core;

import java.util.List;

import com.lianrui.commons.exception.BusinessException;


/**
 * 功能描述：数据接口
 *
 * @param <D> Domain 实体类型
 * @param <T> ID Type 编码类型
 * 2015年12月20日 下午5:20:32
 */
public interface IDao<P, D, T> extends IOperate<P, D, T> {
	
	static final int MAX_AUTOCOMMIT_SIZE = 1000;
	
	@SuppressWarnings("unchecked")
	void add(D... d) throws BusinessException;

	@SuppressWarnings("unchecked")
	void delete(T... id) throws BusinessException;

	void update(D d) throws BusinessException;

	D unique(T id) throws BusinessException;

	@SuppressWarnings("unchecked")
	List<D> get(T... id) throws BusinessException;

	List<D> list(P page) throws BusinessException;
	
	int count(P page) throws BusinessException;
	
	void setMaxAutoCommitSize(int maxAutoCommitSize);
	
	int getMaxAutoCommitSize();
	
	public enum OperateType {
		
		add, delete, update, unique, get, list, count;
		
		public String getNamespaceId(Class<?> clazz) {
			return clazz.getName() + "." + this.name();
		}
		
		public String getNamespaceId(Object obj) {
			return obj.getClass().getName() + "." + this.name();
		}
		
		public static String getStatement(@SuppressWarnings("rawtypes") Class<? extends IDao> daoClazz, String method) {
			return daoClazz.getName() + "." + method;
		}
	}
}
